package com.dr.cmdb.core.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.bson.types.ObjectId;

import java.io.IOException;

/**
 * @ProjectName: cmdb
 * @Package: com.dr.cmdb.core.config
 * @Description: java类作用描述
 * @Author: duanrui
 * @CreateDate: 2021/5/20 22:21
 * @Version: 1.0
 * <p>
 * Copyright: Copyright (c) 2021
 */
public class ObjectIdSerializer extends JsonSerializer<ObjectId> {

    @Override
    public void serialize(ObjectId value, JsonGenerator jsonGen,
                          SerializerProvider provider) throws IOException {
        jsonGen.writeString(value.toString());
    }
}
